package com.atgouwu.mall.product.controller;

import com.atgouwu.mall.common.utils.R;
import com.atgouwu.mall.product.service.ProductService;
import com.atgouwu.mall.product.vo.SearchParam;
import com.atgouwu.mall.product.vo.SearchResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品
 */
@Api(tags = "商品")
@RestController
@RequestMapping("product/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    //根据条件搜索商品(从数据库)
    @ApiOperation(value = "搜索商品", notes = "根据条件搜索商品(从数据库)")
    @PostMapping(value = "/api/searchDb")
    public R searchDb(@RequestBody SearchParam param) {
        SearchResult result = productService.searchDb(param);
        return R.ok().put("data", result);
    }

}
